<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:include="public/page_css::page_css ('确认收货调整')"/>

<body>
<div class="layui-fluid larry-wrapper">
    <div class="layui-row layui-col-space30">
        <div class="layui-col-xs24">
            <section class="panel panel-padding">
                <form id="form1" class="layui-form layui-form-pane" action="">
                    <div class="step-content" id="simplewizardinwidget-steps">
                        <div class="step-pane active" id="simplewizardinwidgetstep1">
                            <div>&nbsp;</div>
                            <input type="hidden" name="id">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="border:none;">货品编号</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="hpbh" style="border:none;"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label" style="border:none;">货品名称</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="hpmc" style="border:none;"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">操作人员</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="czry" placeholder="操作人员" lay-verify="required"
                                               autocomplete="off" class="layui-input "/>
                                    </div>
                                </div>

                            </div>
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <label class="layui-form-label" style="border:none;">预期数量</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="yqsl" name="yqsl" style="border:none;"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="border:none;">收货数量</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="xssl" style="border:none;"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">收货库位</label>
                                    <div class="layui-input-inline">
                                        <select lay-ignore="lay-ignore" class="js-data-example-ajax" id="selectId"
                                                name="telephone1" select2 style="width: 193px"></select>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <label class="layui-form-label" style="border:none;">货品批次</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="hppc" style="border:none;"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" style="border:none;">生产日期</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="scrq" style="border:none;"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">现收数量</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="xsid" name="xssl"  lay-verify="required|number"
                                               autocomplete="off" class="layui-input "/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">

                            <div class="layui-inline">
                                <label class="layui-form-label">破损数量</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="psid" name="pssl" value="0" lay-verify="required|number"
                                           autocomplete="off" class="layui-input "/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">拒收数量</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="cc" name="jssl" value="0" placeholder="拒收数量"
                                           lay-verify="required|number"
                                           autocomplete="off" class="layui-input "/>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" th:value="${id}" id="kid">
                    </div>
                </form>
            </section>
        </div>
    </div>
</div>
</body>
<div th:include="public/public_js::public_js"></div>

<script th:inline="javascript">
    $(function () {

        //拒收数量大于0的时候触发事件
        $('#cc').bind('input propertychange', function () {
            var jssl = $("#cc").val();
            if (jssl > 0) {
                $("#dlg").show();
                $("#jsyy").attr("lay-verify", "required");
            } else {
                $("#dlg").hide();
                $("#jsyy").removeAttr("lay-verify");
            }
        });
        //现收数量不能大于当前查询的数量
        $('#xsid').bind('input propertychange', function () {
            var xsid=$("#xsid").val();//现收数量
            var psid=$("#psid").val();//破损数量
            var yqid=$("#yqid").val();//预期收货数量
            var znum=xsid+psid;//总数量
            if (xsid>yqid||xsid<0){//如果修改的数量大于开始的数量或者小于0 还原回去
                $("#xsid").val(yqid);
            }
        });
    })
</script>
<script>
    layui.use(['myform', 'zzpUtils', 'form', 'jquery'], function () {
        var form = layui.form,
            zzpUtils = layui.zzpUtils,
            $ = layui.jquery;
        /*select2单选*/
        /*zzpUtils.select2({
            elem: "#selectId",
            url: "/wmslibraryposition/getZCLibrarysBymc",
            data: function (params) {
                var query = {
                    mc: params.term,
                    lx: 4
                };
                console.log("&&&&&&&&&"+query);
                return JSON.stringify(query);
            }
        });*/
        zzpUtils.select2({
            elem: "#selectId",
            url: "/wmspalletsorting/getKwBymc",
            data: function (params) {
                var query = {
                    mc: params.term,
                    lx: 4
                };
                return JSON.stringify(query);
            }
        });
        var ids = $("#kid").val();
        zzpUtils.action({
            url: "/wmsEstimatedArrivalOrderDetailed/ConfirmationASN",
            data: JSON.stringify({id: ids}),
            success: function (data) {
                zzpUtils.loadJsonDataToForm(data);
            }, error: function (xhr, textStatus) {
                console.log(textStatus);
                console.log(xhr)
            }
        });

        window.submitFunction = function (data) {
            console.log("来提交了");
            console.log(data);
        }
        form.on("submit(form1btn)", function (data) {

            zzpUtils.confirm("是否确定修改", function (index) {
                parent.$('#xssl').val(data.field.xssl);//现收数量
                parent.$('#pssl').val(data.field.pssl);//破损数量
                parent.$('#czry').val(data.field.czry);//操作人员
                parent.$('#jssl').val(data.field.jssl);//拒收数量
                parent.$('#jsyy').val(data.field.jsyy);//拒收原因
                parent.$('#pid').val(1);//判断
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
                /*   zzpUtils.action({
                       url: "/wmspalletsorting/editTZ",
                       data: JSON.stringify(data.field),
                       success: function (data) {
                           setTimeout(function () {
                               var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                               parent.layer.close(index); //再执行关闭
                               top.layer.msg(data.title);
                           }, 500);
                       }, error: function (xhr, textStatus) {
                           console.log(textStatus);
                           console.log(xhr)
                       }
                   })*/
            })
            $("#form1btn").remove();
            return false;
        });
    });

</script>
</html>